﻿using AppService.IService.System_setting;
using Domain.Entity.System_setting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers.System_setting
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EmployeeController : ControllerBase
    {

        public IEmployeeService employeeService { get; set; }

        /// <summary>
        /// 分页查询员工
        /// </summary>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <param name="uid"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        [HttpGet("{currentPage},{pageSize}")]
        public IActionResult GetAll(int currentPage, int pageSize, int uid, string? value)
        {
            List<Ment_employee> ment_Employees = employeeService.GetAll(currentPage, pageSize, uid, value);
            return Ok(ment_Employees);
        }

        /// <summary>
        /// 查询员工数量
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetCount(int uid, string? value)
        {
            int ment_Employees = employeeService.GetCount(uid, value);
            return Ok(ment_Employees);
        }

        /// <summary>
        /// 查询所以角色类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetTypeRole()
        {
            List<Ment_role> roles = employeeService.GetTypeRole();
            return Ok(roles);
        }

        /// <summary>
        /// 逻辑删除员工
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        [HttpDelete("{id}")]
        public IActionResult DelEmployee(int uid)
        {
            bool flag = employeeService.DelAll(uid);
            return Ok(flag);
        }

        [HttpGet("{id}")]
        public IActionResult GetDeparts(int id)
        {
            string ment_Depart = employeeService.GetDeparts(id);
            return Ok(new { ment_Depart });
        }

        [HttpGet("{id}")]
        public IActionResult GetRoles(int id)
        {
            Ment_role ment_Role = employeeService.GetRoles(id);
            return Ok(ment_Role);
        }

    }
}
